﻿using UnityEngine;
using System.Collections;

public class SpawnEnemy : MonoBehaviour {

	private float counter;
	private float counterC;
	private float counterM;
	
	public GameObject Bloco;
	public GameObject Bullet;
	public GameObject Coin;
	public GameObject Meteor;
	
	private Vector3 posicao;
	
	// Use this for initialization
	void Start () 
	{
		this.Bloco = (GameObject)Resources.Load("Prefabs/prefabBloco");
		this.Bullet = (GameObject)Resources.Load("Prefabs/prefabBullet");		
		this.Coin = (GameObject)Resources.Load("Prefabs/prefabCoin");
		this.Meteor = (GameObject)Resources.Load("Prefabs/prefabMeteor");
	}
	
	// Update is called once per frame
	void Update () 
	{
		counter += Time.deltaTime;
		counterC += Time.deltaTime;
		counterM += Time.deltaTime;
		if(this.counter > 2)
		{
			Instantiate_Bloco();
			//Instantiate_Bullet();
			this.counter = 0;
		}
		if(this.counterC > 3)
		{
			//Instantiate_Coin();
			this.counterC = 0;	
		}
		if(this.counterM > 7)
		{
			//Instantiate_Meteor();
			this.counterM = 0;
		}
		
	}
	
	public void Instantiate_Bloco()
    {
        //this.local = this.gameObject.GetComponent<Transform>();
        this.posicao = new Vector3(6.0f, 0.0f, 0.0f);
        Instantiate(Bloco, this.posicao, Quaternion.identity);
    }
	
	public void Instantiate_Bullet()
    {
        //this.local = this.gameObject.GetComponent<Transform>();
        this.posicao = new Vector3(6.0f, 4.0f, 0.0f);
        Instantiate(Bullet, this.posicao, Quaternion.identity);
    }
	public void Instantiate_Coin()
    {
        //this.local = this.gameObject.GetComponent<Transform>();
        this.posicao = new Vector3(7.0f, 0.0f, 0.0f);
        Instantiate(Coin, this.posicao, Quaternion.identity);
    }
	public void Instantiate_Meteor()
    {
        //this.local = this.gameObject.GetComponent<Transform>();
        this.posicao = new Vector3(-4.0f, 4.0f, 0.0f);
        Instantiate(Meteor, this.posicao, Quaternion.identity);
    }
}
